package com.sparkflow.mysqlbinlog.clickhousesync.utils;

import java.time.*;
import java.time.format.DateTimeFormatter;

/**
 * 时间工具类
 * 处理MySQL和ClickHouse之间的时间格式转换
 *
 * @author Mr_xiaoZH
 * @date 2025-07-23
 */
public class TimeUtil {
    private static final ZoneId ZONE = ZoneId.of("Asia/Shanghai");
    private static final DateTimeFormatter FORMATTER =
            DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZONE);
    public static String toDateTimeStringMs_0(long timestampMillis) {
        Instant instant = Instant.ofEpochMilli(timestampMillis);
        ZonedDateTime zdt = instant.atZone(ZoneId.of("GMT-0")); // 假设目标时区是 GMT+8
        return zdt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

}
